
; TestController must be restarted before any changes in this file will be used.
; Manual is here: https://lygte-info.dk/project/TestControllerConfigDevice%20UK.html



#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ZC,ET4401
#name East Tester ET4401
#handle ET4401
#removeline 15kHz 15000
#removeline 20kHz 20000
#removeline 40kHz 40000
#removeline 50kHz 50000
#removeline 80kHz 80000
#removeline 100kHz 100000
#removeline #cmdSetup number Frequency
#removeline VariableFrequency


; UNTESTED
#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ZC,ET4402
#name East Tester ET4402
#handle ET4402
#removeline 40kHz 40000
#removeline 50kHz 50000
#removeline 80kHz 80000
#removeline 100kHz 100000
#removeline #cmdSetup number Frequency
#removeline VariableFrequency


; UNTESTED
#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ZC,ET4410
#name East Tester ET4410
#handle ET4410
#removeline #cmdSetup number Frequency
#removeline VariableFrequency






; UNTESTED
#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ZC,ET4501
#name East Tester ET4501
#handle ET4501
#removeline 100Hz 100
#removeline 120Hz 120
#removeline 200Hz 200
#removeline 400Hz 400
#removeline 800Hz 800
#removeline 1kHz 1000
#removeline 2kHz 2000
#removeline 4kHz 4000
#removeline 8kHz 8000
#removeline 10kHz 10000
#removeline 15kHz 15000
#removeline 20kHz 20000
#removeline 40kHz 40000
#removeline 50kHz 50000
#removeline 80kHz 80000
#removeline 100kHz 100000
#removeline #cmdSetup comboboxhot Frequency
#replaceText VariableFrequency Hz 10 10000


; UNTESTED
#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ZC,ET4502
#name East Tester ET4502
#handle ET4502
#removeline 100Hz 100
#removeline 120Hz 120
#removeline 200Hz 200
#removeline 400Hz 400
#removeline 800Hz 800
#removeline 1kHz 1000
#removeline 2kHz 2000
#removeline 4kHz 4000
#removeline 8kHz 8000
#removeline 10kHz 10000
#removeline 15kHz 15000
#removeline 20kHz 20000
#removeline 40kHz 40000
#removeline 50kHz 50000
#removeline 80kHz 80000
#removeline 100kHz 100000
#removeline #cmdSetup comboboxhot Frequency
#replaceText VariableFrequency Hz 10 20000


; UNTESTED
#metadef
#author TheDefpom_ http://www.TheDefpom.com
#idString ZC,ET4510
#name East Tester ET4510
#handle ET4510
#removeline 100Hz 100
#removeline 120Hz 120
#removeline 200Hz 200
#removeline 400Hz 400
#removeline 800Hz 800
#removeline 1kHz 1000
#removeline 2kHz 2000
#removeline 4kHz 4000
#removeline 8kHz 8000
#removeline 10kHz 10000
#removeline 15kHz 15000
#removeline 20kHz 20000
#removeline 40kHz 40000
#removeline 50kHz 50000
#removeline 80kHz 80000
#removeline 100kHz 100000
#removeline #cmdSetup comboboxhot Frequency
#replaceText VariableFrequency Hz 10 100000








#meta
#author TheDefpom http://www.TheDefpom.com
#idString ZC,ET44xx
#name East Tester ET4xxx
#handle ET4xxx
#port comfixedbaud
#baudrate 115200
#driver SCPIx

#charset ISO-8859-1



;***********************************************************************************
; Rev 1.1 Release 19th October 2021
; Written by Scott - TheDefpom 
; Website: http://www.TheDefpom.com 
; Electronics Repair Videos: https://www.youtube.com/TheDefpom
;***********************************************************************************
; Please add any notes about 3rd party changes or future definition updates below:
;
;
;
;
;
;
;
;
;
;
;***********************************************************************************


#notes 
Rev 1.1 Release 19th October 2021
Written by Scott - TheDefpom
Website: http://www.TheDefpom.com 
Electronics Repair Videos: https://www.youtube.com/TheDefpom

Currently only tested with the ET4401, but it should also work with the ET4402, ET4410, ET4501, ET4502, ET4510

NOTE: Meter may not respond to multiple command SCPI, it will only see the first command !

; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6) 
; Format: #value ColumnName Unit Format {Selector}
; Selector is only used when column layout varies with mode, this often require the use of #cmdMode
;
; the #value 2nd is to catch the 2nd function where it does not currently flag up with a mode,
; once that is corrected it wont be needed anymore.
; Primary functions are Auto, C, ECAP, L, Z, R, DCR
; 2nd functions are ESR, X, D, Q, THR (Angle) - THR is returned as "¦È" (\xa6\xc8) which is probaby the Phase symbol
;
#value Unknown _ SI Auto
#value Capacitance F SI Cs,Cp,ECs,ECp,ECAP
#value Inductance H SI Ls,Lp
#value Impedance Ohm SI Zs,Zp
#value Resistance Ohm SI Rs,Rp
#value DC_Resistance Ohm SI DCR
#value ESR Ohm SI ESR
#value Reactance Ohm SI X
#value Dissipation % SI D
#value Quality_Factor Q D4 Q
#value Angle Deg D2 PHI
;#value 2nd _ SI




; How to poll for data, this is used for table and #values?
; a #askMode, #cmdMode and #prepareSample is used before this is string is used.
; Number of returned values must match number of columns defined with #value (allowing for selector use)
; This is a single line command
#askValues :FETC?

; Format of answer: s= ???? f=float, u=remove trailing letters, x=skip, *=Zero upper case values if this value is 0
; *** returned format from ET4xxx is value1mode, value1, value2mode, value2 ****
; filters the response string to strip out sections, x removes a section, so xsxs removes the 1st and 3rd sections, leaving only the 2nd and 4th which are the values
#askValuesReadFormat xsxs


; Accept this delay when reading values (seconds)
#readingDelay 2

; Mode change have a longer delay on reading values (seconds)
#modeChangeDelay 4


; String to ask about actual meter mode, it is mostly used for DMM's
; This is a single line command
;#askMode :FUNC:IMP:A?;
#askMode :FETC?
#askModeMathFormat getElement(value,0)+";"+replace(getElement(value,2),"\xa6\xc8","PHI");
#modeFromValue getElement(value,0)+";"+replace(getElement(value,2),"\xa6\xc8","PHI");


; When one of these commands are used through the command interface a new configuration will be done before using #askMode
; Only one word for each #mayModifyMode
; Specify command without initial colon and in the shortest possible form
;#mayModifyMode 


; Prepare the meter to response to #askValues
;#prepareSample arm:sour imm;:arm:count 1;:trig:sour imm;:trig:count 1;:trig:samp:count 1;init

; Initial commands to meter when establishing connection, used to disable local control
; commented out as turning this on locks the front panel controls, and we dont need to use it !
;#initCmd  SYST:REM

; Final command to meter before breaking connection, used to restore local control - Doesnt seem to work well on the ET4xxx, leaves it in REMOTE mode!
#finalCmd SYST:LOC



; This type will specify the handle name for the first device with this type
; This makes it possible to easy get generic handle names for a setup, that will work with a script
;#interfaceType DMM BMM
#interfaceType LCR
#interface readValue 1




;********************************************************
; Handle column type tracking
; This is only being used to display the active mode in the setup window
;********************************************************
; Hack to determine and track what mode the instrument is in as there are two parallel modes.
; :FUNC:IMP:A - Primary funcions - AUTO,L,C,Z,DCR,ECAP,R
; :FUNC:IMP:C - 2nd functions - ESR, X, D, Q, Angle
; :FUNC:IMP:EQU - Series/Parallel mode
;********************************************************
#scpiCmd ModeAuto none?
:setvar: myMode="AUTO"

#scpiCmd ModeL none?
:setvar: myMode="L"

#scpiCmd ModeC none?
:setvar: myMode="C"

#scpiCmd ModeR none?
:setvar: myMode="R"

#scpiCmd ModeZ none?
:setvar: myMode="Z"

#scpiCmd ModeDCR none?
:setvar: myMode="DCR"

#scpiCmd ModeECAP none?
:setvar: myMode="ECAP"


#scpiCmd ModeX none?
:setvar: myMode2="X"

#scpiCmd ModeD none?
:setvar: myMode2="D"

#scpiCmd ModeQ none?
:setvar: myMode2="Q"

#scpiCmd ModeTHR none?
:setvar: myMode2="THR"

#scpiCmd ModeESR none?
:setvar: myMode2="ESR"


#scpiCmd ModeSERial none?
:setvar: myMode3="SERial"

#scpiCmd ModePALlel none?
:setvar: myMode3="PALlel"


; handle the myMode query, killing it, and returning the value
#scpiCmd myMode? none?
:readmath: myMode

; handle the myMode2 query, killing it, and returning the value
#scpiCmd myMode2? none?
:readmath: myMode2

; handle the myMode3 query, killing it, and returning the value
#scpiCmd myMode3? none?
:readmath: myMode3






;*************************************************************
; Mode Window
;*************************************************************

; Strings to configure device in different modes, using these forces a mode check/change
; When used to select mode, first parameter must match a #value (4 parameter) and second parameter must match what #askMode returns
; It can also be used for just checking the mode, then the #value (4 parameter) must match what #askMode returns
; First parameter is also used in shortcut menu

#cmdModeLayout 6 2


#cmdMode ECAP ECAP
:FUNC:IMP:A ECAP;ModeECAP;[400];

#cmdMode C C
:FUNC:IMP:A C;ModeC;[400];

#cmdMode L L
:FUNC:IMP:A L;ModeL;[400];

#cmdMode Z Z
:FUNC:IMP:A Z;ModeZ;[400];

#cmdMode R R
:FUNC:IMP:A R;ModeR;[400];

#cmdMode DCR DCR
:FUNC:IMP:A DCR;ModeDCR;[400];



#cmdMode ESR ESR
:FUNC:IMP:B ESR;ModeESR;[400];

#cmdMode D D
:FUNC:IMP:B D;ModeD;[400];

#cmdMode X X
:FUNC:IMP:B X;ModeX;[400];

#cmdMode Q Q
:FUNC:IMP:B Q;ModeQ;[400];

; this one might need the handle changing, as the meter returns this: ¦È for the phase symbol
#cmdMode Angle Deg
:FUNC:IMP:B THR;ModeTHR;[400];

#cmdMode Auto AUTO
:FUNC:IMP:A AUTO;ModeAuto;[400];

; blank spacers
;#cmdMode







;*************************************************************
; Setup Window
;*************************************************************


#cmdSetup info Active_Mode Info
:read: myMode?
:readmath: getElement("Auto;Electrolytic Capacitance;Capacitance;Inductance;Impedance;Resistance;DC Resistance",listIndex(unQuote(value),"AUTO ECAP C L Z R DCR"," "),";")
:updatemodechange:
:layout:



; *** commented out as it does not change modes in the Mode window, which means the "Current Values" tab doesnt show the correct mode ***
;#cmdSetup comboboxhot Mode
;:read: :FUNC:IMP:A?;
;:write: :FUNC:IMP:A #;[400];Mode#
;:readmath: trim(value)
;:updatemodechange:
;:update: Selector
;Auto AUTO
;Inductance L
;Capacitance C
;Elecrolytic_Capacitance ECAP
;AC_Resistance R
;DC_Resistance DCR
;Impedance Z
;************



;********
; allows for the ET44xx and ET45xx, only difference is fixed steps vs variable freq.
#cmdSetup number Frequency
#cmdSetup comboboxhot Frequency
:read: :FREQ?;
:write: :FREQ #;[400]
:readmath: trim(value)
:string:
100Hz 100
120Hz 120
200Hz 200
400Hz 400
800Hz 800
1kHz 1000
2kHz 2000
4kHz 4000
8kHz 8000
10kHz 10000
15kHz 15000
20kHz 20000
40kHz 40000
50kHz 50000
80kHz 80000
100kHz 100000
VariableFrequency
;********



#cmdSetup radio Function
:read: :FUNC:IMP:B?;
:write: :FUNC:IMP:B #;[400];Mode#
:readmath: trim(value)
:updatemodechange:
:string:
ESR ESR
Dissipation D
Reactance X
Quality_Factor Q
Angle THR




#cmdSetup radio Type
:read: :FUNC:IMP:EQU?;
:write: :FUNC:IMP:EQU #;[400];Mode#
:readmath: trim(value)
:updatemodechange:
:string:
Series SERial
Parallel PALlel



;***************
; this refuses to work... can read the value but wont write it !
;#cmdSetup number Bias_Voltage
;:read: :BIAS:VOLT:LEV?;
;:write: :BIAS:VOLT:LEV #;[400]
;:updatemodechange:
;:readmath: trim(value)
;:string:
;:format: int
;mV 0 1500

; Strangely this one works fine !
#cmdSetup comboboxhot Bias_Voltage
:read: :BIAS:VOLT:LEV?;
:write: :BIAS:VOLT:LEV #;[400]
:updatemodechange:
:readmath: trim(value)
:string:
0mV 0
5mV 5
10mV 10
25mV 25
50mV 50
75mV 75
100mV 100
250mV 250
500mV 500
750mV 750
1V 1000
1.25V 1250
1.5V 1500
;*****************




#cmdSetup radio Speed
:read: :APER?;
:write: :APER #;[400]
:readmath: trim(value)
:updatemodechange:
:string:
Fast FAST
Medium MEDium
Slow SLOW




;#cmdSetup checkbox Impedance_Auto_Range
;:read: :FUNC:IMP:RANG:AUTO?;
;:write: :FUNC:IMP:RANG:AUTO #;[400]
;:readmath: trim(value)
;:update: ZSelector
;:string:
;On OFF ON




; not working, cant seem to figure out correct SCPI command, the one in the manual does not work?
;#cmdSetup comboboxhot Impedance
;:read: :FUNC:IMP:RANG:VAL?;
;:write: :FUNC:IMP:RANG:VAL #;[400]
;:updatemodechange:
;:string:
;30_Ohms 30
;100_Ohms 100
;300_Ohms 300
;1k_Ohms 1000
;3_kOhms 3000
;10_kOhms 10000
;30_kOhms 30000
;100_kOhms 100000




#cmdSetup checkbox Beeper
:read: :SYST:BEEP:STAT?;
:write: :SYST:BEEP:STAT #;[400]
:readmath: trim(value)
:string:
On OFF ON




#cmdSetup checkbox Relative_Measurement
:read: :FUNC:DEV:MODE?;
:write: :FUNC:DEV:MODE #;[400]
:readmath: trim(value)
:updatemodechange:
:string:
On OFF ON



#cmdSetup selector Selector
:read: :FUNC:IMP:A?;
:readmath: trim(value)
:updatemodechange:
:layout:
AUTO Frequency Speed Bias_Voltage Impedance_Range Beeper Relative_Measurement
L Frequency Function Type Speed Bias_Voltage Impedance_Range Beeper Relative_Measurement
C Frequency Function Type Speed Bias_Voltage Impedance_Rangee Beeper Relative_Measurement
ECAP Frequency Function Type Speed Impedance_Range Beeper Relative_Measurement
R Frequency Function Type Speed Bias_Voltage Impedance_Range Beeper Relative_Measurement
DCR Type Speed Bias_Voltage Impedance_Range Beeper Relative_Measurement
Z Frequency Function Type Speed Bias_Voltage Impedance_Range Beeper Relative_Measurement



;#cmdSetup selector ZSelector
;:read: :FUNC:IMP:RANG:AUTO?;
;:readmath: trim(value)
;:updatemodechange:
;:layout:
;ON Impedance_Auto_Range
;OFF Impedance_Auto_Range Impedance



